﻿using MigratorCore.Actions;
using MigratorCore.Objects;
using MigratorCore.Status;
namespace MigratorCore
{
    /// <summary>
    /// Threading Run Action Class
    /// </summary>
    internal sealed class MigratorRunAction
    {
        private ISourceAction source;
        private IDestinationAction destination;
        public MigratorRunAction(ref ISourceAction SourceAction, ref IDestinationAction DestinationAction)
        {
            source = SourceAction;
            destination = DestinationAction;
        }

        public void Run()
        {
            source.Get();
            foreach (Event e in source.Status)
                if (e.EventType == EventType.CriticalError) return;
            destination.Objects = source.Objects;
            destination.Set();
        }
    }
}
